# include <bits/stdc++.h>
using namespace std;


int main()
{
    string s;
    cin >> s;
    map<char,int> p;
    p['*'] = 2;
    p['/'] = 2;
    p['+'] = 1;
    p['-'] = 1;

    int top = -1;
    int max = 0;
    char sta[10];
    for(int i=0;i<s.size();i++)
    {
        if(top+1>=max)
            max = top+1;
        if(s[i]>='a' && s[i]<='z')
            cout << s[i];
        else if(s[i]=='(')
            sta[++top] = s[i];
        else if(s[i]=='+'||s[i]=='-'||s[i]=='*'||s[i]=='/')
        {
            // 如果s[i]符号的算数优先级低于或等于栈顶符号，则弹出栈顶，然后s[i]入栈
            while(p[sta[top]]>=p[s[i]] && top>-1)
            {
                cout << sta[top--];
            }
            sta[++top] = s[i];
            
        }
        else if(s[i]==')')
        {
            while(sta[top]!='(')
                cout<<sta[top--];
            top--;
        }

    }
    while(top!=-1)
        cout << sta[top--];
    cout << endl << max;
    return 0;
}